package com.example.demo.controller;

import com.example.demo.entity.DataSource;
import com.example.demo.service.DatasourceService;
import com.example.demo.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/datasource")
@CrossOrigin
public class DatasourceController {

    @Autowired
    public DatasourceService datasourceService;
    @GetMapping("/getAll")
    public Result<List<DataSource>> upload(){
       return Result.success(datasourceService.getAll());
    }

    @PostMapping("/create")
    public Result<Boolean> create(@RequestBody DataSource dataSource){
        return Result.success(datasourceService.create(dataSource));
    }

    @PostMapping("/update")
    public Result<Boolean> update(@RequestBody DataSource dataSource){
        return Result.success(datasourceService.update(dataSource));
    }
}
